package com.xique.door.project.miniprogram.controller;

import com.xique.common.core.web.controller.BaseController;
import com.xique.common.core.web.domain.AjaxResult;
import com.xique.door.project.miniprogram.bean.request.MiniAddFamilyRequest;
import com.xique.door.project.miniprogram.bean.request.MiniClaimHouseRequest;
import com.xique.door.project.miniprogram.bean.request.MiniDelFamilyRequest;
import com.xique.door.project.miniprogram.bean.request.MiniImageRequuest;
import com.xique.door.project.miniprogram.biz.service.IMiniHouseBizService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author shd
 * @create 2022/4/12 16:49
 */
@RestController
@RequestMapping("/house")
public class MiniHouseController extends BaseController {

    @Autowired
    private IMiniHouseBizService houseBizService;

    @GetMapping("/getAreaList")
    public AjaxResult getAreaList(Long projectId) {
        return houseBizService.getAreaList(projectId);
    }

    @GetMapping("/getBuildingList")
    public AjaxResult getBuildingList(Long areaId) {
        return houseBizService.getBuildingList(areaId);
    }

    @GetMapping("/getHouseList")
    public AjaxResult getHouseList(Long buildingId) {
        return houseBizService.getHouseList(buildingId);
    }

    @PostMapping("/claimHouse")
    public AjaxResult claimHouse(@RequestBody @Valid MiniClaimHouseRequest request) {
        return houseBizService.claimHouse(request);
    }

    @GetMapping("/myHouses")
    public AjaxResult myHouses() {
        return houseBizService.myHouses();
    }

    @GetMapping("/myFamilys")
    public AjaxResult myFamilys(Long houseId, Long parkId) {
        return houseBizService.myFamilys(houseId, parkId);
    }

    @PostMapping("/addFamily")
    public AjaxResult addFamily(@RequestBody @Valid MiniAddFamilyRequest request) {
        return houseBizService.addFamily(request);
    }

    @PostMapping("/updateImge")
    public AjaxResult updateImge(@RequestBody @Valid MiniImageRequuest request) {
        return houseBizService.updateImge(request);
    }

    @DeleteMapping("delFamily")
    public AjaxResult delFamily(@Valid MiniDelFamilyRequest request) {
        return houseBizService.delFamily(request);
    }

    @GetMapping("/getAreaBuilding")
    public AjaxResult getAreaBuilding(Long houseId) {
        return houseBizService.getAreaBuilding(houseId);
    }

}
